#ifndef GAMESTATE_H_
#define GAMESTATE_H_

#include <vector>

#include "sdl.h"

#include "Player.h"
#include "DevelopmentCard.h"
#include "ResourceSet.h"
#include "GameMap.h"

namespace catan
{

class GameState
{
public:
	GameState();
	virtual ~GameState();
	void end();
	bool isRunning();
	bool getIsFrameDrawn();
	void toggleFrame();
	bool getIsMaskDrawn();
	void toggleMask();
	bool getAreHexagonsDrawn();
	void toggleHexagons();
	bool getIsBackgroundDrawn();
	void toggleBackground();
	void setIsPlacingSettlement(bool isPlacingSettlement);
	bool getIsPlacingSettlement();
	void nextScreen();
	void setScreenNumber(int screenNumber);
	int getScreenNumber();
	void setNumberOfPlayers(int numberOfPlayers);
	int getNumberOfPlayers();
	void nextPlayer();
	int getPlayerIndex();
	void addPlayer(Player player);
	std::vector<Player*> getPlayers();
	void setIsPreStartGame(bool isPreStartGame);
	bool getIsPreStartGame();
	bool getIsRollDiceButtonEnabled();
	void setIsRollDiceButtonEnabled(bool isRollDiceButtonEnabled);
	bool getIsBuyRoadButtonEnabled();
	void setIsBuyRoadButtonEnabled(bool isBuyRoadButtonEnabled);
	bool getIsBuyRoadButtonPressed();
	void setIsBuyRoadButtonPressed(bool isBuyRoadButtonPressed);
	bool getIsBuySettlementButtonEnabled();
	void setIsBuySettlementButtonEnabled(bool isBuySettlementButtonEnabled);
	bool getIsBuySettlementButtonPressed();
	void setIsBuySettlementButtonPressed(bool isBuySettlementButtonPressed);
	bool getIsCityUpgradeButtonEnabled();
	void setIsCityUpgradeButtonEnabled(bool isCityUpgradeButtonEnabled);
	bool getIsCityUpgradeButtonPressed();
	void setIsCityUpgradeButtonPressed(bool isCityUpgradeButtonPressed);
	bool getIsBuyDevelopmentCardButtonEnabled();
	void setIsBuyDevelopmentCardButtonEnabled(bool isBuyDevelopmentCardButtonEnabled);
	bool getIsPlayerTradeButtonEnabled();
	void setIsPlayerTradeButtonEnabled(bool isPlayerTradeButtonEnabled);
	bool getIsPlayerTradeButtonPressed();
	void setIsPlayerTradeButtonPressed(bool isPlayerTradeButtonPressed);
	bool getIsBankTradeButtonEnabled();
	void setIsBankTradeButtonEnabled(bool isBankTradeButtonEnabled);
	bool getIsBankTradeButtonPressed();
	void setIsBankTradeButtonPressed(bool isBankTradeButtonPressed);
	bool getIsEndTurnButtonEnabled();
	void setIsEndTurnButtonEnabled(bool isEndTurnButtonEnabled);
	void rollDice();
	std::vector<int> getRolledDice();
	SDL_Event *pollKeyDownEvent();
	void queueKeyDownEvent(SDL_Event &event);
	SDL_Event *pollMouseButtonDownEvent();
	void queueMouseButtonDownEvent(SDL_Event &event);
	SDL_Event *pollMouseMotionEvent();
	void queueMouseMotionEvent(SDL_Event &event);
	std::vector<DevelopmentCard> &getDevelopmentDeck();
	bool isTheEnd();
	bool canAddRoad(Player &player);
	bool canAddRoad(Player &player, GameMap &gameMap, PathCoordinate road);
	bool canAddSettlement(Player &player);
	bool canAddSettlement(Player &player, GameMap &gameMap, SiteCoordinate settlement);
	bool canCityUpgrade(Player &player);
	bool canCityUpgrade(Player &player, GameMap &gameMap, SiteCoordinate city);
private:
	bool _isRunning;
	bool isFrameDrawn;
	bool isMaskDrawn;
	bool areHexagonsDrawn;
	bool isBackgroundDrawn;
	bool isPreStartGame;
	bool isPlacingSettlement;
	int screenNumber;
	int numberOfPlayers;
	std::vector<Player> players;
	int currentPlayerIndex;
	int indexOfTheWinner;
	std::vector<DevelopmentCard> developmentDeck;
	ResourceSet developmentCost;
	std::vector<int> rndIndexes;
	std::vector<int> dice;
	bool isRollDiceButtonEnabled;
	bool isBuyRoadButtonEnabled;
	bool isBuyRoadButtonPressed;
	bool isBuySettlementButtonEnabled;
	bool isBuySettlementButtonPressed;
	bool isCityUpgradeButtonEnabled;
	bool isCityUpgradeButtonPressed;
	bool isBuyDevelopmentCardButtonEnabled;
	bool isPlayerTradeButtonEnabled;
	bool isPlayerTradeButtonPressed;
	bool isBankTradeButtonEnabled;
	bool isBankTradeButtonPressed;
	bool isEndTurnButtonEnabled;
	
	SDL_Event *keyDownEventRef;
	SDL_Event *mouseButtonDownEventRef;
	SDL_Event *mouseMotionEventRef;
};

}

#endif /*GAMESTATE_H_*/
